<?php

/**
 * Description of paging
 *
 * @author SOUMA
 */
class paging {

    private $model;
    private $model_count;
    private $model_name;
    private  $url;
    private $where;
    private $num_begin;
    private $num_range;
    private $num_page;

    function __construct($model, $url, $where = '', $num_begin = 0, $num_range = 10) {
        $this->where = $where;
        $this->num_begin = $num_begin;
        $this->num_range = $num_range;
        $this->url = $url;
        $this->get_max();
        $this->print_paging();
        $this->model = $model;
    }

    function get_max() {
        $model = new home();
        $max = $model->{$this->model_count}($this->where, $this->num_begin, $this->num_range);
        $this->num_page = round($max / $this->num_range);
    }

    function print_paging() {
        if ($this->num_page > 0) {
            $i = 1;
            echo '<ul';
            while ($i <= $this->num_page) {
                echo '<a href="'.$this->url.'treang-'.$i.'"><li>'.$i.'</li></a>';
                $i++;
            }
            echo '</ul>';
        }
    }

    function get_model() {
        $model = new home();
        if ($this->num_begin != 0) {
            
        }
        $model->{$this->model_name}($this->where, $this->num_begin, $this->num_range);
    }

}
